#!/bin/bash
# help: Run go unit tests
set -ex

cd $(dirname $0)/..

echo Running tests

PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} |  cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"

if [ "$ARCH" = "amd64" ]; then
    RACE="-race"
fi
go test $RACE -v -cover -tags=test ${PACKAGES}
